/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Logico;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author usuario
 */
@Entity
@Table(name = "evento")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Evento.findAll", query = "SELECT e FROM Evento e"),
    @NamedQuery(name = "Evento.findByIdevento", query = "SELECT e FROM Evento e WHERE e.idevento = :idevento"),
    @NamedQuery(name = "Evento.findByNombre", query = "SELECT e FROM Evento e WHERE e.nombre = :nombre"),
    @NamedQuery(name = "Evento.findByDescripcion", query = "SELECT e FROM Evento e WHERE e.descripcion = :descripcion"),
    @NamedQuery(name = "Evento.findByFechaInicio", query = "SELECT e FROM Evento e WHERE e.fechaInicio = :fechaInicio"),
    @NamedQuery(name = "Evento.findByFechaFin", query = "SELECT e FROM Evento e WHERE e.fechaFin = :fechaFin"),
    @NamedQuery(name = "Evento.findByLogo", query = "SELECT e FROM Evento e WHERE e.logo = :logo")})
public class Evento implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @SequenceGenerator(name = "idEvento_generator", sequenceName = "evento_id_seq", allocationSize = 1)
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "idEvento_generator")
    @Column(name = "idevento")
    private Integer idevento;
    @Column(name = "nombre")
    private String nombre;
    @Column(name = "descripcion")
    private String descripcion;
    @Column(name = "fecha_inicio")
    @Temporal(TemporalType.DATE)
    private Date fechaInicio;
    @Column(name = "fecha_fin")
    @Temporal(TemporalType.DATE)
    private Date fechaFin;
    @Column(name = "logo")
    private String logo;
    @JoinTable(name = "evento_has_periodista", joinColumns = {
        @JoinColumn(name = "evento_idevento", referencedColumnName = "idevento")}, inverseJoinColumns = {
        @JoinColumn(name = "periodista_idperiodista", referencedColumnName = "idperiodista")})
    @ManyToMany
    private List<Periodista> periodistaList;
    @ManyToMany(mappedBy = "eventoList")
    private List<Disciplina> disciplinaList;
    @JoinColumn(name = "ceduladirectorlogistica", referencedColumnName = "cedula")
    @ManyToOne
    private Usuario ceduladirectorlogistica;
    @JoinColumn(name = "ceduladirectoradministrativo", referencedColumnName = "cedula")
    @ManyToOne
    private Usuario ceduladirectoradministrativo;
    @JoinColumn(name = "ceduladirectordeportivo", referencedColumnName = "cedula")
    @ManyToOne
    private Usuario ceduladirectordeportivo;
    @JoinColumn(name = "ceduladirectorevento", referencedColumnName = "cedula")
    @ManyToOne(optional = false)
    private Usuario ceduladirectorevento;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "eventoIdevento")
    private List<Competencia> competenciaList;

    public Evento() {
    }

    public Evento(Integer idevento) {
        this.idevento = idevento;
    }

    public Integer getIdevento() {
        return idevento;
    }

    public void setIdevento(Integer idevento) {
        this.idevento = idevento;
    }

    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    public Date getFechaInicio() {
        return fechaInicio;
    }

    public void setFechaInicio(Date fechaInicio) {
        this.fechaInicio = fechaInicio;
    }

    public Date getFechaFin() {
        return fechaFin;
    }

    public void setFechaFin(Date fechaFin) {
        this.fechaFin = fechaFin;
    }

    public String getLogo() {
        return logo;
    }

    public void setLogo(String logo) {
        this.logo = logo;
    }

    @XmlTransient
    public List<Periodista> getPeriodistaList() {
        return periodistaList;
    }

    public void setPeriodistaList(List<Periodista> periodistaList) {
        this.periodistaList = periodistaList;
    }

    @XmlTransient
    public List<Disciplina> getDisciplinaList() {
        return disciplinaList;
    }

    public void setDisciplinaList(List<Disciplina> disciplinaList) {
        this.disciplinaList = disciplinaList;
    }

    public Usuario getCeduladirectorlogistica() {
        return ceduladirectorlogistica;
    }

    public void setCeduladirectorlogistica(Usuario ceduladirectorlogistica) {
        this.ceduladirectorlogistica = ceduladirectorlogistica;
    }

    public Usuario getCeduladirectoradministrativo() {
        return ceduladirectoradministrativo;
    }

    public void setCeduladirectoradministrativo(Usuario ceduladirectoradministrativo) {
        this.ceduladirectoradministrativo = ceduladirectoradministrativo;
    }

    public Usuario getCeduladirectordeportivo() {
        return ceduladirectordeportivo;
    }

    public void setCeduladirectordeportivo(Usuario ceduladirectordeportivo) {
        this.ceduladirectordeportivo = ceduladirectordeportivo;
    }

    public Usuario getCeduladirectorevento() {
        return ceduladirectorevento;
    }

    public void setCeduladirectorevento(Usuario ceduladirectorevento) {
        this.ceduladirectorevento = ceduladirectorevento;
    }

    @XmlTransient
    public List<Competencia> getCompetenciaList() {
        return competenciaList;
    }

    public void setCompetenciaList(List<Competencia> competenciaList) {
        this.competenciaList = competenciaList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idevento != null ? idevento.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Evento)) {
            return false;
        }
        Evento other = (Evento) object;
        if ((this.idevento == null && other.idevento != null) || (this.idevento != null && !this.idevento.equals(other.idevento))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Logico.Evento[ idevento=" + idevento + " ]";
    }
    
}
